package com.mc.read.adminapi;

import com.alibaba.fastjson.JSON;
import com.mc.read.adminapi.jiami.DESUtil;
import com.mc.read.dao.mapper.BooklabelMapper;
import com.mc.read.dao.mapper.UseropinionMapper;
import com.mc.read.dao.mapper.UserreadcollectionMapper;
import com.mc.read.dao.mapper.UserreadhistoryMapper;
import com.mc.read.dao.mapper.sys.SyspermissionMapper;
import com.mc.read.dao.models.Useropinion;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @author liuhao
 * @date 2019/6/5 16:27
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ReadAdminapiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class readTest {

    @Autowired
    BooklabelMapper booklabelMapper;
    @Autowired
    UserreadhistoryMapper userreadhistoryMapper;
    @Autowired
    UserreadcollectionMapper userreadcollectionMapper;
    @Autowired
    SyspermissionMapper syspermissionMapper;
    @Autowired
    UseropinionMapper useropinionMapper;
    @Test
    public void test1(){
        List<Useropinion> useropinionList=useropinionMapper.selectByExampleWithBLOBs(null);
        String str= JSON.toJSONString(useropinionList);
        System.out.println(str);
        //待加密内容
        String result = DESUtil.encrypt(str);
//        String strs = new String(base64en.encode(result));
        System.out.println("加密后："+result);
        //直接将如上内容解密
        try {
            String decryResult = DESUtil.decryptor(result);
            System.out.println("解密后："+new String(decryResult));
            useropinionList=JSON.parseArray(decryResult,Useropinion.class);
            System.out.println(useropinionList.size());
            for (Useropinion u:useropinionList
                    ) {
                System.out.println(JSON.toJSONString(u));
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }

    }
}
